package o;

import android.content.Context;
import com.huawei.appgallery.forum.cards.bean.ForumTitleSortCardBean;
import com.huawei.appgallery.forum.cards.node.ForumTitleSortNode;
import com.huawei.appgallery.forum.comments.card.ForumReplyCardBean;
import com.huawei.appgallery.forum.comments.card.ForumReplyNode;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class bul extends cia {
    private Long ˋ;
    private Long ॱ;

    public bul(Context context) {
        super(context);
    }

    public chz ˋ(long j, int i, int i2, List<CardBean> list) {
        dnd.ॱ("ReplyDataProvider", "addCardChunk, id:" + j + " + cardType:" + i);
        chz ˋ = super.ˋ(j, i, i2, list);
        if (ˋ != null) {
            if (ˋ.ˋ instanceof ForumReplyNode) {
                this.ˋ = Long.valueOf(j);
            } else if (ˋ.ˋ instanceof ForumTitleSortNode) {
                this.ॱ = Long.valueOf(j);
            }
        }
        return ˋ;
    }

    public void ˋ(ForumReplyCardBean forumReplyCardBean) {
        if (this.ˋ != null) {
            chz ॱ = ॱ(this.ˋ.longValue());
            Collection ˏ = ॱ.ˏ();
            List arrayList = new ArrayList();
            arrayList.add(forumReplyCardBean);
            arrayList.addAll(ˏ);
            ॱ.ˊ(arrayList);
            ˊ();
        }
    }

    private void ˊ() {
        chz ॱ = ॱ(this.ॱ.longValue());
        if (ॱ != null) {
            List ˏ = ॱ.ˏ();
            if (ˏ != null && ˏ.size() > 0) {
                CardBean cardBean = (CardBean) ˏ.get(0);
                if (cardBean instanceof ForumTitleSortCardBean) {
                    ForumTitleSortCardBean forumTitleSortCardBean = (ForumTitleSortCardBean) cardBean;
                    int ˊ = forumTitleSortCardBean.ˊ() + 1;
                    if (ˊ > 0) {
                        forumTitleSortCardBean.ˎ(ˊ);
                    }
                }
            }
        }
    }

    public void ˏ(long j) {
        chz ॱ = ॱ(this.ˋ.longValue());
        Collection ˏ = ॱ.ˏ();
        int i = 0;
        while (i < ˏ.size()) {
            ForumReplyCardBean forumReplyCardBean = null;
            if (ˏ.get(i) instanceof ForumReplyCardBean) {
                forumReplyCardBean = (ForumReplyCardBean) ˏ.get(i);
            }
            if (forumReplyCardBean == null || j != forumReplyCardBean.ˊ().ˊ()) {
                i++;
            } else {
                ˏ.remove(i);
                ॱ.ˊ(new ArrayList(ˏ));
                return;
            }
        }
    }
}
